from rest_framework import serializers
from rest_framework.serializers import ModelSerializer

from apps.goods.models import SKUImage, SKU


class ImageSeriazlier(ModelSerializer):
    # 返回图片关联的sku的id值
    sku = serializers.PrimaryKeyRelatedField(read_only=True)

    class Meta:
        model = SKUImage
        fields = ('sku', 'image', 'id')


class SKUSeriazlier(ModelSerializer):
    class Meta:
        model = SKU
        fields = ('id', 'name')
